//
//  DYShopInfoCell.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/21.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYShopInfoCell.h"

@interface DYShopInfoCell ()<UICollectionViewDelegate, UICollectionViewDataSource>

@property (nonatomic,strong)UICollectionView *collectionView;

@end

@implementation DYShopInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(void)dy_initUI
{
    [super dy_initUI];
    
    self.hideSeparatorLabel=YES;
    [self xhq_noneSelectionStyle];
    
    
    self.titleLabel=({
        UILabel *label=[Utils labelWithTitleFontSize:12 textColor:[UIColor xhq_content] alignment:0];
        label;
    });
    
    _collectionView = ({
        UICollectionViewFlowLayout *layout =[[UICollectionViewFlowLayout alloc]init];
//        layout.itemSize = CGSizeMake((kScreenWidth-BILIWIDTH(30))/2,(kScreenWidth-BILIWIDTH(30))/2);
        layout.minimumInteritemSpacing = BILIWIDTH(5);
        layout.minimumLineSpacing =BILIWIDTH(10);
        layout.headerReferenceSize = CGSizeMake(0, 0);
        //        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        
        
        UICollectionView *collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(BILIWIDTH(10), 0, kScreenWidth-BILIWIDTH(20), BILIHEIGHT(0))
                                                             collectionViewLayout:layout];
        collectionView.delegate = self;
        collectionView.dataSource = self;
        collectionView.pagingEnabled=YES;
        collectionView.showsHorizontalScrollIndicator=NO;
        [collectionView registerClass:[DYShopInfoCollectionViewCell  class] forCellWithReuseIdentifier:@"DYShopInfoCollectionViewCell"];
        
        if (@available(iOS 11.0, *)) {
            collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        }
        collectionView.backgroundColor = [UIColor whiteColor];
        collectionView;
    });
    
    [self addSubview:self.collectionView];
    [self addSubview:self.titleLabel];
    
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(BILIWIDTH(10));
        make.top.equalTo(BILIHEIGHT(10));
    }];
    
    [self.collectionView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(BILIWIDTH(10));
        make.right.equalTo(BILIWIDTH(-10));
        make.bottom.equalTo(BILIWIDTH(-1));
        make.top.equalTo(self.titleLabel.bottom).offset(BILIHEIGHT(6));
    }];
    
}

#pragma mark - UICollectionViewDataSource methods
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 3;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake((kScreenWidth-BILIWIDTH(30))/2,BILIHEIGHT(100));
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
   DYShopInfoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DYShopInfoCollectionViewCell" forIndexPath:indexPath];
    cell.showImageView.backgroundColor=[UIColor xhq_red];
    return cell;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end



@implementation DYShopInfoCollectionViewCell 

-(instancetype)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    if (self) {
        [self initView];
    }
    return self;
}
-(void)initView
{
    self.showImageView = ({
        UIImageView *imageView=[Utils imageView];
        imageView.contentMode=UIViewContentModeScaleAspectFill;
        imageView.clipsToBounds=YES;
        [imageView xhq_cornerRadius:5];
        imageView;
    });
    
    [self addSubview:self.showImageView];
    
    [self.showImageView makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(0);
    }];
}
@end

@interface DYShopInfoAuthCell ()

@property (nonatomic,strong)UIImageView *authImageView;
@property (nonatomic,strong)UILabel *authLabel;
@property (nonatomic,strong)UILabel *timeLabel;
@property (nonatomic,strong)UIButton *goAuthButton;

@end

@implementation DYShopInfoAuthCell

-(void)dy_initUI
{
    [super dy_initUI];
    
    
    self.hideSeparatorLabel=YES;
    [self xhq_noneSelectionStyle];
    
    
    self.titleLabel=({
        UILabel *label=[Utils labelWithTitleFontSize:12 textColor:[UIColor xhq_content] alignment:0];
        label.text=@"商家认证";
        label;
    });
    
    self.authImageView = ({
        UIImageView *imageView=[Utils imageViewWithImage:IMG(@"icon_beian")];
        imageView;
    });
    
    self.authLabel =({
        UILabel *label=[Utils labelWithTitleFontSize:14 textColor:[UIColor xhq_content] alignment:0];
        label;
    });
    
    self.timeLabel = ({
        UILabel *label=[Utils labelWithTitleFontSize:13 textColor:[UIColor xhq_content] alignment:0];
        label;
    });
    
    self.goAuthButton = ({
        UIButton *button=[Utils createBtnWithType:UIButtonTypeCustom backgroundColor:WhiteColor action:@selector(goAuthButtonClick) target:self title:@"前往认证" image:nil font:12 textColor:[UIColor xhq_base]];
        [button xhq_cornerRadius:BILIHEIGHT(14)];
        [button xhq_borderColor:[UIColor xhq_base] borderWidth:BILIWIDTH(1)];
        button;
    });
    
    [self addSubview:self.titleLabel];
    [self addSubview:self.authImageView];
    [self addSubview:self.authLabel];
    [self addSubview:self.timeLabel];
    [self addSubview:self.goAuthButton];
    
    
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(BILIWIDTH(10));
        make.top.equalTo(BILIHEIGHT(10));
    }];
    
    [self.authImageView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel);
        make.top.equalTo(self.titleLabel.bottom).offset(BILIHEIGHT(15));
    }];
    
    [self.authLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.authImageView.right).offset(BILIWIDTH(5));
        make.centerY.equalTo(self.authImageView);
    }];
    
    [self.timeLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.authLabel.right).offset(BILIWIDTH(7));
        make.centerY.equalTo(self.authImageView);
    }];
    
    [self.goAuthButton makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.authImageView);
        make.size.equalTo(CGSizeMake(BILIWIDTH(70), BILIHEIGHT(28)));
        make.right.equalTo(BILIWIDTH(-10));
    }];
    
    self.authLabel.text=@"企业未认证";
    
}

-(void)goAuthButtonClick
{
    
}
@end
